<?php
namespace App\Http\Controllers\Validator;
use Validator;

/**
 * Class UserVali
 * @package App\Http\Controllers\Validator
 * 用户表验证器
 */
class UserVali{

    public static function validate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_d_id'             => 'required',//部门ID
            'u_username'         => 'required',//员工姓名
            'u_account_number'   => 'required|unique:user',  //员工的登录账号
            'u_password'         => 'required',//密码
            'sex'                => 'required',//性别
            'birthday'           => 'required',//生日
            'jiguan'             => 'required',//籍贯
            'nation'             => 'required',//民族
            'college'            => 'required',//毕业院校
            //&u_d_id=10&u_username=张彪&u_account_number=13335420289&u_password=123456&sex=1&birthday=1990-08-20&jiguan=籍贯籍贯&nation=汉&college=陕西航空职业技术学院&political_face=团员&speciality=模具设计与制造&record_type=5&people_num=610425199008202356&phone=13335420289&email=540347699@qq.com&address=咸阳礼泉&bank_num=6221887990011252222&bank_remark=建行&personal_profile=个人简介个人简介个人简介&post=5&source=1&remark=备注
            'political_face'     => 'required',//政治面貌
            'speciality'         => 'required',//所学专业
            'record_type'        => 'required',//学历
            'people_num'         => 'required',//身份证号
            'phone'              => 'required',//联系电话
            'email'              => 'required',//邮箱
            'address'            => 'required',//家庭住址
            'bank_num'           => 'required',//银行账号
            'bank_remark'        => 'required',//银行名字
            'personal_profile'   => 'required',//个人简介
            'post'               => 'required',//职务
            'source'             => 'required',//来源
            'remark'             => 'required',//备注
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    public static function saveValidate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_id'               => 'required',//员工ID
            'u_d_id'             => 'required',//部门ID
            'u_username'         => 'required',//员工姓名
            'sex'                => 'required',//性别
            'birthday'           => 'required',//生日
            'jiguan'             => 'required',//籍贯
            'nation'             => 'required',//民族
            'u_status'           => 'required',//账号状态（1正常（审核通过） 2禁用(审核中）3.离职）
            'college'            => 'required',//毕业院校
            //&u_id=24&u_d_id=5&u_username=张彪&u_password=123456&sex=1&birthday=1990-08-20&jiguan=籍贯籍贯&nation=汉&u_status=1&college=陕西航空职业技术学院&political_face=团员&speciality=模具设计与制造&record_type=5&people_num=610425199008202356&phone=13335420289&email=540347699@qq.com&address=咸阳礼泉&bank_num=6221887990011252222&bank_remark=建行&personal_profile=个人简介个人简介个人简介&post=5&source=1&remark=备注
            'political_face'     => 'required',//政治面貌
            'speciality'         => 'required',//所学专业
            'record_type'        => 'required',//学历
            'people_num'         => 'required',//身份证号
            'phone'              => 'required',//联系电话
            'email'              => 'required',//邮箱
            'address'            => 'required',//家庭住址
            'bank_num'           => 'required',//银行账号
            'bank_remark'        => 'required',//银行名字
            'personal_profile'   => 'required',//个人简介
            'post'               => 'required',//职务
            'source'             => 'required',//来源
            'remark'             => 'required',//备注
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    public static function loginValidate($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'u_account_number'        => 'required',
            'u_password'   => 'required',
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }

    /**员工修改自己密码  字段验证
     * @param $params
     * @return bool
     */
    public static function updatePassword($params)
    {
        $return = true;
        $validator = Validator::make($params, [
            'new_password'   => 'required',
            'again_password' => 'required',
        ]);
        if ($validator->fails()) {
            $return = false;
        }
        return $return;
    }
}